package com.sg.business.model.dataset.projectgroup;

import com.mongodb.BasicDBObject;
import com.sg.business.model.IModelConstants;
import com.sg.business.model.Project;
import com.sg.business.model.ProjectGroup;
import com.sg.widgets.commons.dataset.MasterDetailDataSetFactory;

public class ProjectOfProjectGroup extends MasterDetailDataSetFactory {

	public ProjectOfProjectGroup() {
		super(IModelConstants.DB, IModelConstants.C_PROJECT);
	}

	@Override
	protected String getDetailCollectionKey() {
		return Project.F__ID;
	}

	@Override
	protected Object getMasterValue() {
		if (master instanceof ProjectGroup) {
			return new BasicDBObject().append("$in",
					((ProjectGroup) master).getProjectIds());
		}
		return super.getMasterValue();
	}

}
